// Mesh.h provides the attributes included in a Mesh class
//-----------------

#if !defined( MeshH)
#define MeshH

//-----------------
// Includes libraries and other files
#include <cassert>	// for asserts
#include <d3dx9.h>	// DirectX 3D library
#include <string>

#include "constants.h"
//-----------------

class Mesh {
	public:
		// constructor and destructor
		Mesh();
		Mesh( const Mesh& m);
		~Mesh();

		// accessors
		void render() const;
		void render( float tx, float ty, float tz, float sx, float sy, float sz, float ry) const;
		void render( float tx, float ty, float tz, float sx, float sy, float sz) const;
		void render( float x, float y, float z) const;
		void render( DWORD sub_mesh_number) const;
		void render_opacity( const int& o) const;

		std::string get_file_name() const;
		LPD3DXMESH get_mesh() const;

		// mutators
		HRESULT load_mesh( LPDIRECT3DDEVICE9 device, LPCTSTR file_name);
		void material( int);
		void texture( int);
		void set_colour( float r, float g, float b);

		// this function can be used for DirectX 'pre-made' models
		//HRESULT create_mesh( LPDIRECT3DDEVICE9 device, int type, float x, float y, float z);

		// overloaded operators
		bool operator ==( const Mesh& m) const;
		bool operator ==( const std::string& s) const;
		Mesh& operator =( const Mesh& m);

	private:
		void unload_mesh();

		std::string			file_name_;			// name of the file that has been loaded (the name gets deleted if it's an LPCTSTR variable)
		LPDIRECT3DDEVICE9	device_;			// pointer to a rendering device
		LPD3DXMESH			mesh_;				// pointer to a mesh object
		D3DMATERIAL9		*mesh_materials_;	// array of materials for the mesh
		LPDIRECT3DTEXTURE9	*mesh_textures_;	// array of pointers to textures for the mesh
		DWORD				dw_num_materials_;	// number of materials (i.e. sub-meshes) in the mesh
};

#endif